"""
    浅拷贝和深拷贝
"""

import copy

# 浅拷贝
list1 = [1,2,3,4,[10,20,30]]
list2 = list1.copy()
list1[4][1]= 100
print(id(list2))
print(id(list1))
list1.append(100)
print(list1)
print(list2)

print(id(list1[4]))
print(id(list2[4]))

list2 = [1,2,3,[0,0,100]]
list3 = copy.deepcopy(list2)
print(id(list2[3]))
print(id(list3[3]))
list2[3][1] = 100
print(list2)
print(list3)


# 不能深拷贝的情形1 : 非容器类型(数组、字符串、和其它原子类型的对象)
num1 = 1
num2 = copy.copy(num1)
print(num2)
num3 = copy.deepcopy(num1)
print(num3)
print(id(num3))
print(id(num2))
# 元组变量如果只包含原子类型对象(不可变),就不能对其深拷贝
t1 = (1,2,3)
t2 = copy.deepcopy(t1)
print(t1)
print(t2)
print(id(t1))
print(id(t2))